package com.gxar.quick.ar.server.base.model.protocol.client.wechat_mp;

import com.gxar.quick.ar.server.base.model.protocol.common.CommonArItemBorderModel;
import lombok.Data;

import java.util.Objects;

/**
 * 微信小程序 - 边框信息
 *
 * @author zxh
 * @version 1.0
 * @created 2024/01/02.
 */
@Data
public class WechatMpClientArItemBorderModel {

    private String id;

    private String type;

    private String subType;

    private String linkType;

    private String linkUrl;

    private Double innerX;

    private Double innerY;

    private Double innerWidth;

    private Double innerHeight;

    private Double width;

    private Double height;

    private String position;

    private String rotation;

    private String scale;

    private String fillType;

    private Boolean isBorder;

    private String alphaModel;

    private String effect;

    public static WechatMpClientArItemBorderModel from(CommonArItemBorderModel inputModel) {
        if (Objects.isNull(inputModel)) {
            return null;
        }

        WechatMpClientArItemBorderModel outputModel = new WechatMpClientArItemBorderModel();
        outputModel.setId(inputModel.getId());
        outputModel.setType(inputModel.getType());
        outputModel.setSubType(inputModel.getSubType().getName());
        if (Objects.nonNull(inputModel.getLinkType())) {
            outputModel.setLinkType(inputModel.getLinkType().getName());
        }
        outputModel.setLinkUrl(inputModel.getEncodeLinkUrl());
        outputModel.setInnerX(inputModel.getInnerX());
        outputModel.setInnerY(inputModel.getInnerY());
        outputModel.setInnerWidth(inputModel.getInnerWidth());
        outputModel.setInnerHeight(inputModel.getInnerHeight());

        outputModel.setWidth(inputModel.getWorldSize().getWidth());
        outputModel.setHeight(inputModel.getWorldSize().getHeight());
        outputModel.setPosition(inputModel.getPosition().toString());
        outputModel.setRotation(inputModel.getRotation().toString());
        outputModel.setScale(inputModel.getScale().toString());

        if (Objects.nonNull(inputModel.getFillType())) {
            outputModel.setFillType(inputModel.getFillType().getName());
        }

        outputModel.setIsBorder(true);
        outputModel.setAlphaModel(inputModel.getAlphaMode());
        outputModel.setEffect(inputModel.getEffect().getName());

        return outputModel;
    }
}
